<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'shake_animation.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
	#d1{
width:20px;
height:20px;
background:red;
position:absolute;
}
	</style> 
  </head>
<script type="text/javascript" src="<%=basePath%>/jquery-1.2.6.js"></script>
<script>

$.fn.jump = function (options) {
	    var defaults = {"init_top":0};
        var options =  $.extend(defaults, options);  
        options.init_top = $(this).offset().top;
        this.each(function () {
        		var g = 0.980 * 37.795276*0.001;//加速px/1ms
				var height = 30;//初始高度px
				var cost_energy = 3;//损失高度
				
				var this_cost_time = 0; 
				var this_top = 0;
				var this_top_temp = 0;
				var this_height = height;
				var animateStr = '$(this)';
			
			  	for(var i = 0,len=Math.floor(height/cost_energy);i<len;i++){
				  	this_top = $(this).offset().top;
				  	this_top_temp = this_top - this_height;
				  	this_cost_time = Math.sqrt(2*this_height/g);
				  	animateStr += '.animate({"top":"'+this_top_temp+'px"},'+this_cost_time+').animate({"top":"'+this_top+'px"},'+this_cost_time+')';
				    this_height = this_height - cost_energy;
			  	}
			  	if(animateStr){
			  		eval(animateStr);
			  		alert(animateStr);
			  	}
        });
        return this;
};

$(document).ready(function(){
$("#d1").jump();
/*
	var g = 0.980 * 37.795276*0.001;//加速px/1ms
	var height = 30;//初始高度px
	var cost_energy = 3;//损失高度
	
	var this_cost_time = 0; 
	var this_top = 0;
	var this_top_temp = 0;
	var this_height = height;
	var animateStr = '$("#d1")';

  	for(var i = 0,len=Math.floor(height/cost_energy);i<len;i++){
	  	this_top = $("#d1").offset().top;
	  	this_top_temp = this_top - this_height;
	  	this_cost_time = Math.sqrt(2*this_height/g);
	  	animateStr += '.animate({"top":"'+this_top_temp+'px"},'+this_cost_time+').animate({"top":"'+this_top+'px"},'+this_cost_time+')';
	    this_height = this_height - cost_energy;
  	}
  	if(animateStr){
  		eval(animateStr);
  		$("#d1").after(animateStr);
  	}
  	*/
});


</script>
  
  <body>
  
  <br/>
  <br/>
  <br/>
  <br/>
  <br/>
  <br/>
  <br/>
<div id="d1">
</div>
    http://127.0.0.1:81/MyDemos/tip_light3.jsp
  </body>
</html>
